#Boa:Frame:cadastroServico_Frame

import wx
from ControleServico import *
from FrameServicos import *

def create(parent):
    return cadastroServico_Frame(parent)

[wxID_CADASTROSERVICO_FRAME, wxID_CADASTROSERVICO_FRAMEBUTTON1, 
 wxID_CADASTROSERVICO_FRAMEBUTTON2, wxID_CADASTROSERVICO_FRAMESTATICBOX1, 
 wxID_CADASTROSERVICO_FRAMESTATICTEXT1, wxID_CADASTROSERVICO_FRAMESTATICTEXT2, 
 wxID_CADASTROSERVICO_FRAMESTATICTEXT3, wxID_CADASTROSERVICO_FRAMESTATICTEXT4, 
 wxID_CADASTROSERVICO_FRAMESTATICTEXT5, wxID_CADASTROSERVICO_FRAMESTATICTEXT6, 
 wxID_CADASTROSERVICO_FRAMESTATICTEXT7, wxID_CADASTROSERVICO_FRAMETEXTCTRL1, 
 wxID_CADASTROSERVICO_FRAMETEXTCTRL2, wxID_CADASTROSERVICO_FRAMETEXTCTRL3, 
] = [wx.NewId() for _init_ctrls in range(14)]

class cadastroServico_Frame(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_CADASTROSERVICO_FRAME,
              name=u'cadastroServico_Frame', parent=prnt, pos=wx.Point(461,
              239), size=wx.Size(413, 262), style=wx.DEFAULT_FRAME_STYLE,
              title=u'cadastroServico_Frame')
        self.SetClientSize(wx.Size(397, 224))
        self.SetBackgroundColour(wx.Colour(255, 255, 255))

        self.staticBox1 = wx.StaticBox(id=wxID_CADASTROSERVICO_FRAMESTATICBOX1,
              label=u'Cadastrar Novo Servi\xe7o', name='staticBox1',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(397, 224), style=0)

        self.staticText1 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT1,
              label=u'Servi\xe7o ID', name='staticText1', parent=self,
              pos=wx.Point(16, 32), size=wx.Size(72, 19), style=0)
        self.staticText1.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Times New Roman'))

        self.staticText2 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT2,
              label=u'Nome', name='staticText2', parent=self, pos=wx.Point(16,
              72), size=wx.Size(40, 19), style=0)
        self.staticText2.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Times New Roman'))

        self.staticText3 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT3,
              label=u'Pre\xe7o', name='staticText3', parent=self,
              pos=wx.Point(16, 112), size=wx.Size(38, 19), style=0)
        self.staticText3.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Times New Roman'))

        self.textCtrl1 = wx.TextCtrl(id=wxID_CADASTROSERVICO_FRAMETEXTCTRL1,
              name='textCtrl1', parent=self, pos=wx.Point(104, 32),
              size=wx.Size(72, 21), style=0, value=u'')
        self.textCtrl1.Enable(False)

        self.textCtrl2 = wx.TextCtrl(id=wxID_CADASTROSERVICO_FRAMETEXTCTRL2,
              name='textCtrl2', parent=self, pos=wx.Point(72, 72),
              size=wx.Size(264, 21), style=0, value=u'')

        self.textCtrl3 = wx.TextCtrl(id=wxID_CADASTROSERVICO_FRAMETEXTCTRL3,
              name='textCtrl3', parent=self, pos=wx.Point(72, 112),
              size=wx.Size(64, 21), style=0, value=u'')

        self.button1 = wx.Button(id=wxID_CADASTROSERVICO_FRAMEBUTTON1,
              label=u'Cadastrar Servi\xe7o', name='button1', parent=self,
              pos=wx.Point(176, 176), size=wx.Size(99, 24), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_CADASTROSERVICO_FRAMEBUTTON1)

        self.button2 = wx.Button(id=wxID_CADASTROSERVICO_FRAMEBUTTON2,
              label=u'Cancelar', name='button2', parent=self, pos=wx.Point(296,
              176), size=wx.Size(75, 24), style=0)
        self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button,
              id=wxID_CADASTROSERVICO_FRAMEBUTTON2)

        self.staticText4 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT4,
              label=u'R$', name='staticText4', parent=self, pos=wx.Point(144,
              112), size=wx.Size(20, 19), style=0)
        self.staticText4.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Times New Roman'))

        self.staticText5 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT5,
              label=u'20 Reais = 20.00', name='staticText5', parent=self,
              pos=wx.Point(200, 112), size=wx.Size(83, 13), style=0)

        self.staticText6 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT6,
              label=u'20 Reais e Cinquenta Centavos = 20.50',
              name='staticText6', parent=self, pos=wx.Point(200, 128),
              size=wx.Size(193, 13), style=0)

        self.staticText7 = wx.StaticText(id=wxID_CADASTROSERVICO_FRAMESTATICTEXT7,
              label=u'Ex:', name='staticText7', parent=self, pos=wx.Point(176,
              112), size=wx.Size(16, 13), style=0)
        self.staticText7.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Tahoma'))

    def __init__(self, parent):
        self._init_ctrls(parent)
        
        CS = ControleServico()
        self.textCtrl1.SetLabel(CS.GerarNovoID())
        
    def OnButton1Button(self, event):
        auxCS = ControleServico()
        
        ServicoID = self.textCtrl1.GetValue()
        nome = self.textCtrl2.GetValue()
        preco = self.textCtrl3.GetValue()
        
        try:
            auxCS.cadastrarServicoComInterface(ServicoID, nome, preco)
            
            m = 'Servi\xe7o Cadastrado Com Sucesso'
            c = 'Cadastro de Servi\xe7o'
            wx.MessageBox(m,c,wx.OK)
            
            import FrameServicos
            FrameServicos.create(None).Show(True)
            self.Close()
            
        except:
            m = 'Erro'
            c = 'Cadastro de Servi\xe7o'
            wx.MessageBox(m,c,wx.OK)
            
            import FrameServicos
            FrameServicos.create(None).Show(True)
            self.Close()
            
        

    def OnButton2Button(self, event):
        import FrameServicos
        tela = FrameServicos.create(None)
        tela.Show()
        self.Close()
